﻿<%@ Page Title="Edit Product Page" Language="C#" MasterPageFile="  ~/template/Site.Master" AutoEventWireup="true" CodeBehind="EditProduct.aspx.cs" Inherits="EAAdmin.EditProduct" %>

<%@ Import Namespace="EA.DTO" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <script src="public/calendar/jquery_min.js" type="text/javascript"></script>
    <link href="public/calendar/calendar-blue.css" type="text/css" rel="stylesheet" />
    <script src="public/calendar/jquery.dynDateTime.js" type="text/javascript"></script>
    <script src="public/calendar/calendar-en.js" type="text/javascript"></script>

    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery("#beginDay").dynDateTime();
        });

        function UpdateProduct() {
            var category = document.getElementById("txtCategory").value;

            var beginDate = document.getElementById("beginDay").value;
            if (category == "") {
                alert("Category can not be empty");
                category.focus();
                return false;
            }
            else if (beginDate == "") {
                alert("Begindate can not be empty");
                beginDate.focus();
                return false;
            }
            else {
                document.forms["frmUpdateProduct"].submit();
            }
            return true;
        }
    </script>

    <form id="frmUpdateProduct" action="EditProduct.aspx?action=Update" runat="server">
        <% if (Attributes.ContainsKey("product"))
           {
               ProductTO product = (ProductTO)Attributes["product"];
        %>
        <input type="hidden" name="id" value="<%=product.ID %>" />


        <div class="page_name">Product Updation</div>
        <div class="error">
            <%                
               String alert = "";
               if (Attributes.ContainsKey("err"))
               {
                   alert = (String)Attributes["err"];
            %>
            <div class="message">
                <div><%=alert%></div>
            </div>
            <%  }
                if (Attributes.ContainsKey("success"))
                {
                    alert = (String)Attributes["success"];
            %>
            <div class="message_alert">
                <div><%=alert%></div>
            </div>
            <%  } %>
        </div>
        <table style="margin-top: 15px; margin-left: 350px; width: 300px; text-align: left">
            <tr>
                <td style="width: 100px">Name</td>
                <td style="width: 200px"><%=product.Name %></td>
            </tr>
            <tr>
                <td>Detail</td>
                <td><%=product.Detail %></td>
            </tr>
            <tr>
                <td>FloorPrice</td>
                <td><%=product.FloorPrice %></td>
            </tr>
            <tr>
                <td>Step Price</td>
                <td><%=product.StepPrice %></td>
            </tr>
            <tr>
                <td>Updated Date</td>
                <td><%=product.UpdateDate %></td>
            </tr>
            <tr>
                <td>Total Bidday</td>
                <td><%=product.TotalBidDay %></td>
            </tr>

            <% if (Attributes.ContainsKey("listProductCategory"))
               {
                   List<ProductCategoryTO> listProductCategory = (List<ProductCategoryTO>)Attributes["listProductCategory"];
            %>
            <tr>
                <td>Category</td>
                <td>
                    <select style="width: 200px;" id="txtCategory" name="txtCategory">
                        <% for (int i = 0; i < listProductCategory.Count; i++)
                           { 
                        %>
                        <option <%=product.ProductCategoryID==listProductCategory[i].ID?"selected":""%> value="<%=listProductCategory[i].ID %>"><%=listProductCategory[i].Name %></option>
                        <%  }
                        %>
                    </select>
                </td>
            </tr>
            <%  }
            %>
            <tr>
                <td>Begin Date</td>
                <td>
                    <input type="text" value='<%=product.BeginDate.ToString("dd/MM/yyyy") %>' class="textbox" name="beginDay" id="beginDay" /></td>
            </tr>

            <tr>
                <td>Begin Hour</td>
                <td>
                    <input type="text" value='<%=product.BeginDate.ToString("hh:mm") %>' class="textbox" name="beginHour" id="beginHour" /></td>
            </tr>

            <tr>
                <td colspan="2">
                    <input type="button" class="button" style="float: right" value="Submit" onclick="UpdateProduct()" /></td>
            </tr>
        </table>
        <%  }       
        %>
    </form>
</asp:Content>
